package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.ui.contract.LoginContract
import com.baizan.daka.mvp.model.UserModel
import com.baizan.daka.mvp.model.bean.LoginInfoBean
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.ModifyPasswordContract
import com.baizan.daka.util.Md5

class ModifyPasswordPresenter(val mView: ModifyPasswordContract.View) : BasePresenter(),
    ModifyPasswordContract.Presenter {


    private val userModel: UserModel by lazy {
        UserModel()
    }

    override fun modifyPassword(account: String, password: String, newPassword: String) {
        mView.showLoadingDialog()
        userModel.modifyPassword(account,Md5.getPasswordMd5(password)
                ,Md5.getPasswordMd5(newPassword))
            .subscribe(object :CommonSubscriber<Any>(compositeDisposable){
                override fun onCallNext(t: Any?) {
                    mView.modifyPasswordSuccess()
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }

            })
    }


}

